package com.first.group.newhouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.first.group.newhouse.entity.NewHouseImgEntity;
import com.first.group.newhouse.service.NewHouseImgService;
import com.first.group.common.utils.PageUtils;
import com.first.group.common.utils.R;



/**
 * 这是新房图片表
 *
 * @author zy
 * @email 2067065884@qq.com
 * @date 2021-10-14 19:04:42
 */
@RestController
@RequestMapping("newhouse/newhouseimg")
public class NewHouseImgController {
    @Autowired
    private NewHouseImgService newHouseImgService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = newHouseImgService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{newImgId}")
    public R info(@PathVariable("newImgId") Long newImgId){
		NewHouseImgEntity newHouseImg = newHouseImgService.getById(newImgId);

        return R.ok().put("newHouseImg", newHouseImg);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody NewHouseImgEntity newHouseImg){
		newHouseImgService.save(newHouseImg);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody NewHouseImgEntity newHouseImg){
		newHouseImgService.updateById(newHouseImg);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] newImgIds){
		newHouseImgService.removeByIds(Arrays.asList(newImgIds));

        return R.ok();
    }

}
